﻿CREATE PROCEDURE [ProductImage].[GetProductImageMetadata]
	@TenantId uniqueidentifier
AS

-- 1st
SELECT
	PIS.SizeId,
	PIS.WellKnownSizeCode,
	PIS.Width,
	PIS.Height,
	PIS.DisplayOrder,
	PIS.DefaultName,
	PIS.DefaultMissingImagePath
FROM
	ProductImageSize PIS
WHERE
	PIS.TenantId = @TenantId


-- 2nd
SELECT
	PISL.SizeId,
	PISL.CultureId,
	PISL.Name,
	PISL.MissingImagePath
FROM
	ProductImageSizeLocalization PISL 
	INNER JOIN ProductImageSize PIS ON PISL.TenantId = PIS.TenantId AND PISL.SizeId = PIS.SizeId
WHERE
	PIS.TenantId = @TenantId

-- 3rd
SELECT
	PIV.ViewId,
	PIV.WellKnownViewCode,
	PIV.DisplayOrder,
	PIV.DefaultName
FROM
	ProductImageView PIV
WHERE
	PIV.TenantId = @TenantId
	
-- 4th
SELECT
	PIVL.ViewId,
	PIVL.CultureId,
	PIVL.Name
FROM
	ProductImageViewLocalization PIVL
	INNER JOIN ProductImageView PIV ON PIVL.TenantId = PIV.TenantId AND PIVL.ViewId = PIV.ViewId
WHERE
	PIV.TenantId = @TenantId
